define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'user/integral/index',
                    // add_url: 'user/user/add',
                    // edit_url: 'user/user/edit',
                    // del_url: 'user/user/del',
                    multi_url: 'user/integral/multi',
                    table: 'user_integral',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'createtime',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'user_id', title: __('用户ID'), sortable: true},
                        {field: 'group.nickname', title: __('用户昵称'), sortable: true},
                        {field: 'wolk_num', title: __('行走步数'), sortable: true},
                        {field: 'score', title: __('兑换积分'), sortable: true},
                        {field: 'createtime', title: __('创建日期'), formatter: Table.api.formatter.datetimeM, operate: 'RANGE', addclass: 'datetimerange', sortable: false},
                        {field: 'updatetime', title: __('最后更新时间'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: false},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});